using UnityEngine;
using System.Collections;

public class GameLogic : MonoBehaviour {

    public Transform monsterSpawns;
    public GameObject Monster;

    public float timeInterval = 2;
    float contadorTempo = 0;

	// Use this for initialization
	void Start () {
        monsterSpawns = GameObject.FindWithTag("Monsterspawn").transform;
	
	}
	
	// Update is called once per frame
	void Update () {

        if (Time.time > timeInterval + contadorTempo)
        {
            Spawn();
        }

        if (Input.GetButton("CloseGame"))
        {
            Application.Quit();
        }
	
	}

    void Spawn()
    {
        GameObject go = (GameObject) Instantiate (Monster, monsterSpawns.position, monsterSpawns.rotation);
        contadorTempo = Time.time;

    }
}
